/*     */ package com.qmsk.business.member.memberCashCouponRule.controller;
/*     */ 
/*     */ import com.qmsk.business.member.memberCashCouponRule.dao.MemberCashCouponRuleDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/memberCashCoupRule"})
/*     */ public class MemberCashCouponRuleController
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(MemberCashCouponRuleController.class);
/*     */ 
/*     */   @Autowired
/*     */   private MemberCashCouponRuleDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  53 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  55 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, nPageSize);
/*  56 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  58 */       logger.error(e);
/*  59 */       ResponseUtils.setErrorMsgResponse(
/*  60 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/cal/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Integer id)
/*     */   {
/*     */     try
/*     */     {
/*  69 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(id);
/*  70 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  72 */       logger.error(e);
/*  73 */       ResponseUtils.setErrorMsgResponse(
/*  74 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  89 */     String sGsonInData = request.getParameter("data");
/*     */     try
/*     */     {
/*  92 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/*  93 */       DbConnection.commit();
/*  94 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  95 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  96 */         response);
/*     */     } catch (Exception e) {
/*  98 */       DbConnection.rollback();
/*  99 */       logger.error(e);
/* 100 */       ResponseUtils.setErrorMsgResponse(
/* 101 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 102 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response) {
/* 109 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 111 */       String[] strParams = id.split(",");
/* 112 */       int nResult = this.dao.deleteParams(strParams);
/* 113 */       DbConnection.commit();
/* 114 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 115 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 116 */         response);
/*     */     } catch (Exception e) {
/* 118 */       DbConnection.rollback();
/* 119 */       logger.error(e);
/* 120 */       ResponseUtils.setErrorMsgResponse(
/* 121 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 122 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 137 */     String id = request.getParameter("id");
/* 138 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 140 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 141 */       if (g == null) {
/* 142 */         ResponseUtils.setErrorMsgResponse(
/* 143 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 144 */           response);
/*     */       } else {
/* 146 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 147 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 148 */           RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 149 */           response);
/*     */       }
/* 151 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 153 */       DbConnection.rollback();
/* 154 */       logger.error(e);
/* 155 */       ResponseUtils.setErrorMsgResponse(
/* 156 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request) + ":" + 
/* 157 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.memberCashCouponRule.controller.MemberCashCouponRuleController
 * JD-Core Version:    0.5.3
 */